﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Red.Controls.Converters
{
    public class GreaterThanOrEqualConverter<T> : IValueConverter where T : IComparable
    {
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            return ( (IComparable)value ).CompareTo( parameter ) >= 0;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }
    
    public class LessThanOrEqualConverter<T> : IValueConverter where T : IComparable
    {
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            return ( (IComparable)value ).CompareTo( parameter ) <= 0;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }

    public sealed class GreaterThanOrEqualSingleConverter : GreaterThanOrEqualConverter<float> { }
    public sealed class LessThanOrEqualSingleConverter : LessThanOrEqualConverter<float> { }
}
